package com.cl.edu.web.admin;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;

import com.cl.common.CrudActionSupport;
import com.cl.core.orm.Page;
import com.cl.edu.entity.Ts;
import com.cl.edu.service.admin.TssManager;
import com.opensymphony.xwork2.ActionSupport;

/**
 * 投诉建议处理 
 * @author Administrator
 *
 */
public class TssAction extends CrudActionSupport<Ts>{
	@Autowired
	private TssManager tssManager;
	
	private Page<Ts> page = new Page<Ts>();
	private Ts entity;
	private Integer id;
	private String filter_isReplay;

	
	@Override
	public String list() throws Exception {
		if (!page.isOrderBySetted()) {
			page.setOrderBy("createTime");
			page.setOrder(Page.DESC);
		}
		page = tssManager.getTsPage(page);
		return SUCCESS;
	}
	
	//删除投诉建议信息
	@Override
	public String delete() throws Exception {
		try {
			tssManager.deleteTs(id);
			addActionMessage("删除投诉建议成功");
		} catch (Exception e) {
			addActionMessage("删除投诉建议失败");
		}
		return list();
	}

	@Override
	public String input() throws Exception {
		return INPUT;
	}

	//回复投诉建议
	@Override
	public String save() throws Exception {
		entity.setReplayTime(new Date());
		entity.setIsReplay(1);
		tssManager.updateTs(entity);
		addActionMessage("更新投诉建议成功");

		return list();
	}

	@Override
	protected void prepareModel() throws Exception {
		if(id ==null){
			entity = new Ts(); 
		} else {
			entity = tssManager.getTs(id);
		}
		
	}

	public Ts getModel() {
		return entity;
	}

	public Page<Ts> getPage() {
		return page;
	}

	public void setPage(Page<Ts> page) {
		this.page = page;
	}

	public Ts getEntity() {
		return entity;
	}

	public void setEntity(Ts entity) {
		this.entity = entity;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getFilter_isReplay() {
		return filter_isReplay;
	}

	public void setFilter_isReplay(String filterIsReplay) {
		filter_isReplay = filterIsReplay;
	}
	
}
